<?php
namespace app\admin\controller;
use app\admin\model\Goods as GoodsModel;
use think\Request;

//商品管理
class Goods extends BaseController
{
    public function __construct()
    {
        $this->goods = new GoodsModel();
        parent::__construct();
    }
    //列表
    //  wxy
    public function index(){
        $res = $this->goods->getList();
        $page = $res->render();
        $count = count($res);
        $this->assign("page",$page);
        $this->assign("list",$res);
        $this->assign("count",$count);
        return $this->fetch();
    }
    //修改,添加
    //  wxy
    public function goods_edit(){
        if(input("post.")){
            return $this->goods->goodsEdit();
        }else{

            if(input("get.")){
                $id = input("get.id");
                $rs = $this->goods->getInfo(['good_id'=>$id]);
            }else{

                $rs = $this->goods->getEModel("goods");
            }
            $this->assign('res',$rs);
            return $this->fetch();
        }
    }
    // 上传图片
    public function img()
    {
       $file = request()->file();
       print_r($file);

    }
    //删除
    //  wxy
    public function goods_del(){
        $id = input("post.id");
        $res = $this->goods->goodsDel($id);
        return $res;
    }
}
?>